#include "stdafx.h"
#include "Checkbox.h"
#include "..\..\..\..\EdgeGraphics\HUD.h"
#include "..\..\..\..\EdgeContent\ContentManager.h"

void checkbox_onclicked(void**);

Checkbox::Checkbox(void)
{
	float width = 0, height = 0;
	texture = ContentManager::GetInstance()->LoadTexture("Content/Textures/check.mat", &width, &height);
	clientRect.setWidth(width);
	clientRect.setHeight(height);
	OnClicked.Subscribe(Functor<mouse_event_handler>(checkbox_onclicked, 0));
}

/*virtual*/ Checkbox::~Checkbox(void)
{

}

/*virtual*/ void Checkbox::Draw(void) /*override*/
{	
	if (checked)
		UiElement::Draw();
	Hud::GetInstance()->DrawRectangle((int)clientRect.left- 2, (int)clientRect.top - 2, 25, 25, VectorHelper::vector_4::white);
}

void checkbox_onclicked(void** params)
{
	Checkbox* me = (Checkbox*)params[0];
	me->setChecked(!me->getChecked());
}